{*******************************************************************************
* The contents of this file are used with permission, subject to the Mozilla   *
* Public License Version 1.1 (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at      *
* http://www.mozilla.org/MPL/                                                  *
*                                                                              *
* Software distributed under the License is distributed on an "AS IS" basis,   *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License.    *
*                                                                              *
* The Original Code is distributed as part of the "mediate" product and is     *
* Copyright (C) @home media limited. All Rights Reserved.                      *
*                                                                              *
* Email: support@athomemedia.co.uk                                             *
* Web:   http://www.athomemedia.co.uk                                          *
*******************************************************************************}

unit UpgradeForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseMsgForm, StdCtrls, ExtCtrls, pngimage;

type
  TfrmUpgradeVersion = class(TfrmBaseMessage)
    procedure FormCreate(Sender: TObject);
    procedure btCentreClick(Sender: TObject);
    procedure btRightClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmUpgradeVersion: TfrmUpgradeVersion;

implementation

{$R *.dfm}

uses ApplicationManager, Utilities;

procedure TfrmUpgradeVersion.FormCreate(Sender: TObject);
begin
  inherited;

  // Show version number for latest version available
  with ApplicationManagerInstance.VersionManager do
    lbVersion.Caption := ProductName + ' ' + LatestVersion;

  lbTitle.Caption := 'Upgrade mediate to';
  lbDesc.Caption := 'A new version of mediate is now available for download. ' +
                    'If you would like to visit our website to review the ' +
                    'release notes or download the new version please click ' +
                    'the relevant button below to open a browser window.';

  // Disable download links if version info not populated
  with ApplicationManagerInstance.VersionManager do
  begin
    btCentre.Enabled := (VersionInfoURL <> '');
    btRight.Enabled := (DownloadURL <> '');
  end;
end;

procedure TfrmUpgradeVersion.btCentreClick(Sender: TObject);
begin
  inherited;

  // Display release notes for new version
  DisplayBrowser(ApplicationManagerInstance.VersionManager.VersionInfoURL);
end;

procedure TfrmUpgradeVersion.btRightClick(Sender: TObject);
begin
  inherited;

  // Display download link in browser for new version
  DisplayBrowser(ApplicationManagerInstance.VersionManager.DownloadURL);
end;

end.
